package com.qufadai.reader.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.qufadai.reader.entity.TickerEntity;

public interface TickerRepository extends JpaRepository<TickerEntity, Integer> {

	public List<TickerEntity> findBySource(Integer source);

	public List<TickerEntity> findBySourceAndUpdated(Integer source,
			Long updated);

	@Query("SELECT min(t.sell) FROM TickerEntity t WHERE t.coinType = ?1")
	public List<TickerEntity> getMinSell(String coinType);

	@Query("FROM TickerEntity t WHERE t.source = ?1 AND t.coinType = ?2 ORDER BY t.id DESC")
	public List<TickerEntity> findBySourceAndCoinType(Integer source,
			String coinType);

	public TickerEntity fetchLastBySourceAndCoinType(Integer source,
			String coinType);
}
